set nocompatible "Needed by Vundle
filetype off "Needed by Vundle
set rtp+=~/.vim/bundle/Vundle.vim "Add Vundle to runtime path

call vundle#begin()
  Plugin 'VundleVim/Vundle.vim' "Vundle
  Plugin 'vim-airline/vim-airline' "Cool statusline
  Plugin 'vim-airline/vim-airline-themes' "Airline themes
  Plugin 'Shougo/neocomplete.vim' "Tab-complete code
  Plugin 'Shougo/neosnippet.vim' "Snippet support
  Plugin 'Shougo/neosnippet-snippets' "Snippet list
  Plugin 'Shougo/context_filetype.vim' "Allow neosnippet to switch filetype on context
  Plugin 'kien/ctrlp.vim' "Fuzzy file/buffer finding/switching
  Plugin 'ludovicchabant/vim-gutentags' "ctag management
  Plugin 'scrooloose/syntastic' "Syntax checker
  Plugin 'tpope/vim-fugitive' "Useful git commands
  Plugin 'notpratheek/vim-luna' "Nice theme
  Plugin 'https://notabug.org/SylvieLorxu/vim-betterK.git' "Improve K command
  Plugin 'https://notabug.org/SylvieLorxu/vim-friendlyremark.git' "Friendly remark
call vundle#end()

"Hide startup message
set shortmess+=I

"Store backups together
set directory=~/.vim/backups//

"Keep undo history between sessions
set undofile
set undodir=~/.vim/undo/

"Incremental search
set incsearch

"Autoindent with tab being 4 spaces
set autoindent
set tabstop=4
set expandtab

"[airline] Always show numbered listed of buffers
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#buffer_nr_show=1

"[airline] Show bottom line always, hide vim mode
set laststatus=2
set noshowmode

"[airline] Remove pause after leaving insert mode
set timeoutlen=50

"Background buffers (no force saving when switching)
set hidden

"[ctrlp] Don't split when opening a new file
let g:ctrlp_open_new_file = 'r'

"[gutentags] Don't pollute project dirs
let g:gutentags_cache_dir = '~/.vim/tags/'

"[neocomplete] Use tab to select a completion, Ctrl+K to expand a snippet,
"Ctrl+H to close Neocomplete
let g:neocomplete#enable_at_startup = 1
imap <C-k>     <Plug>(neosnippet_expand_or_jump)
smap <C-k>     <Plug>(neosnippet_expand_or_jump)
xmap <C-k>     <Plug>(neosnippet_expand_target)
imap <expr><TAB>
 \ pumvisible() ? "\<C-n>" :
 \ neosnippet#expandable_or_jumpable() ?
 \    "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
inoremap <expr><C-h> pumvisible() ? "\<C-y>" : "\<C-h>"

"Theming
syntax enable
colorscheme luna-term
let g:airline_theme='luna'
let g:airline_powerline_fonts=1 "Requires powerline fonts!
set cursorline

"Friendly startup messages
autocmd VimEnter * FriendlyRemark

"Save as sudo with w!! (when lacking root)
cmap w!! w !sudo tee % >/dev/null

set t_Co=256
set term=xterm-256color

map <F2> :bprevious<CR>
map <F3> :bnext<CR>
map <F4> :buffers<CR>
map <F5> :%y+<CR>
map <F12> :bd!<CR>
